# write by hashaki
# first edit on 2018/12/08
# last change on 2018/12/09
# 为做市商的账户管理，做市商有多个账户的需求，与其他引擎交易不一样
# TODO : 支持多账户对打切换
import json
from collections import defaultdict
class MarketBroker:
    def __init__(self):
        self.cash={}                      # 现金流
        self.pos={}                       # 账户持仓
        self.orderList=None               # 账户下单列表
        self.settint_path=''              # 用户账户设置的json文件路径

    def getOrderList(self,orderList):
        '''从市商引擎那里获取到下单列表，orderList={'limitBuy':[[price,volume],...],'limitSell':[[price,volume],...] '''
        self.orderList=orderList

    def getAccountSetting(self):
        '''获取账号设置信息'''
        pass
    
    def limitBuy(self,price,volume):
        '''限价单发单'''
        pass
    
    def limitSell(self,price,volume):
        '''限价单发单'''
        pass
    
    def cancelOrder(self,orderID=None):
        '''取消订单'''
        pass
    
    def cancelOrders(self):
        '''取消所有挂单'''
        pass
    
    def getAccountPos(self):
        '''获取账户所有持仓'''
        return
    
    def getAccountCash(self):
        '''获取账户现金流'''
        return

    def getAccountOrder(self):
        '''获取账户下单(未成交)列表'''
        return

    def testAccount(self,exchange,pos,cash):
        '''用于测试的虚拟账户，exchange是哪个交易所账户，pos为持仓，cash为现金流'''
        self.cash['exchange']=cash
        self.pos['exchange']=pos